<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:03 GMT -->
<head>
	<base href="<%=basePath%>">
    <meta charset="utf-8">
    <title>试卷列表</title>
    
   <%@ include file="/common/common_css.jsp" %>
</head>

<body class="gray-bg">
    <div class="wrapper animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>试卷列表</h5>
        </div>
        <div class="ibox-content">
            <div>
                <div class="form-inline conditionForm" role="form">
                    
                    <div class="form-group">
                        <span>试卷名称: </span>
                        <input id="examPaperName" class="form-control" type="text" >
                    </div>
                    <button type="button" class="btn btn-success" onclick="searchInfo();" ><i class="glyphicon glyphicon-search"></i> 查询</button>
                    <button type="button" class="btn btn-success" onclick="resetCondition();" ><i class="glyphicon glyphicon-remove"></i> 重置</button>
                </div>
            </div>
            <div id="toolbar">
		        <button id="add" class="btn btn-success" onclick="showDialog('#myModal','添加试卷','examPaper/add');">
		            <i class="glyphicon glyphicon-plus"></i> 添加
		        </button>
		        <button id="add" class="btn btn-danger" onclick="batchDelete('examPaper/batchDel','id');">
		            <i class="glyphicon glyphicon-remove"></i> 批量删除
		        </button>
		    </div>
            <table id="examPaperList"
            	data-url="examPaper/list" data-id-field="id" data-side-pagination="server" 
            	data-method="post" data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
            	data-pagination="true" data-page-list="[10, 25, 50, 100, ALL]" data-page-size="10"
            	data-show-columns="true" data-show-refresh="true"  data-show-export="true" data-toolbar="#toolbar">
                 <thead>
                     <tr>
                     	<th data-field="state" data-checkbox="true"></th>
                        <th data-field="id">编号</th>
                        <th data-field="name">试卷名称</th>
                        <th data-field="xxx" data-formatter="partFormatter">试题组成</th>
                        <th data-formatter="operateFormatter">操作</th>
                     </tr>
                 </thead>
             </table>
             
             <div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
                 <div class="modal-dialog modal-lg">
                 	
                     <div class="modal-content animated bounceInRight">
                         <div class="modal-header">
	                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	                        <h4 class="modal-title text-left">添加试卷</h4>
	                    </div>
                         <div class="modal-body">
                         	这是一个表单
                         </div>
                         <div class="modal-footer">
                             <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                             <button type="button" class="btn btn-primary" onclick="changeNames();">保存</button>
                         </div>
                     </div>
                 </div>
             </div>
             
             </div>
         </div>
    </div>
    <%@ include file="/common/common_js.jsp" %>
	<script type="text/javascript">
		var $table = $("#examPaperList");
		$table.bootstrapTable({
			queryParams: function(params){
				params["name"] = $("#examPaperName").val();
				return params;
			}
		});

		//自定义试卷组成列显示格式
		function partFormatter(value,row,index) {
			console.log(row.examPaperPartsList);
			var str = "";
			$.each(row.examPaperPartsList,function(){
				str += "<b>"+this.partName + "</b>["+this.quesCount+"] ";
			});
			return str == "" ? "-" : str;
		}
		
		//自定义操作列
		function operateFormatter(value, row, index) {
	        return [
	            '<a href="javascript:void(0)" title="Remove" onclick="deleteRecord(\'examPaper/delete\','+row.id+');">',
	            '<i class="glyphicon glyphicon-remove"></i>',
	            '</a>&nbsp;&nbsp;',
	            '<a href="examPaper/view/'+row.id+'.shtml" target="_blank" title="试卷预览" >',
	            '<i class="glyphicon glyphicon-eye-open"></i>',
	            '</a>&nbsp;&nbsp;',
	            '<a href="examPaper/export?id='+row.id+'" title="导出试卷" >',
	            '<i class="glyphicon glyphicon-share"></i>',
	            '</a>'
	        ].join('');
        }
		
		function searchInfo(){
			$table.bootstrapTable("refresh");
		}

		function changeNames(){
	    		//表单提交之前修改策略明细的名字
	    		$("#strategeDetails tbody tr").each(function(i){
	    			$(":input",$(this)).each(function(){
	    				var oldName = $(this).attr("name");
	    				var newName = oldName.replace(/\[\d+\]/,"["+i+"]");
	    				$(this).attr("name",newName);
	    			});
	    		})
	    		
	    		//进行表单验证
	    		
	    		submitForm();
	    	}
		
	</script>
	<script type="text/javascript" src="js/axems-common.js"></script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:06 GMT -->
</html>

